package com.cloud.simplespringboot.listener;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.SpringApplicationRunListener;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.core.env.ConfigurableEnvironment;

/**
 * @author kangwen
 */
public class TestSpringApplicationRunListener implements SpringApplicationRunListener {

	private final SpringApplication application;

	private final String[] args;

	public TestSpringApplicationRunListener(SpringApplication application, String[] args) {
		this.application = application;
		this.args = args;
	}

	@Override
	public void starting() {
		System.out.println("ioc 容器创建之前");
	}

	@Override
	public void environmentPrepared(ConfigurableEnvironment environment) {
		System.out.println("ioc 容器 environmentPrepared");
	}

	@Override
	public void contextPrepared(ConfigurableApplicationContext context) {
		System.out.println("ioc 容器 context准备就绪");
	}

	@Override
	public void contextLoaded(ConfigurableApplicationContext context) {
		System.out.println("ioc 容器 contextLoaded");
	}

	@Override
	public void started(ConfigurableApplicationContext context) {
		System.out.println("ioc 容器 started");
	}

	@Override
	public void running(ConfigurableApplicationContext context) {
		System.out.println("ioc 容器 running");
	}

	@Override
	public void failed(ConfigurableApplicationContext context, Throwable exception) {
		System.out.println("ioc 容器 failed");
	}
}
